package com.cw.jeeyt.service.converter.facade;

import java.util.List;

import com.cw.jeeyt.service.bo.facade.FacadeEnumBo;
import com.cw.jeeyt.dao.model.facade.FacadeEnumDo;
import com.cw.lang.common.utils.CollectionUtil;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;

/**
 * 接口枚举转换类
 *
 * @author chenw
 * @date 2019-11-02 14:16:40
 */
public class FacadeEnumConverter {

    /**
    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static FacadeEnumBo do2Bo(FacadeEnumDo model) {
        if (model == null) {
            return null;
        }
        return FacadeEnumBo.builder()
            .id(model.getId())
            .enumCode(model.getEnumCode())
            .enumName(model.getEnumName())
            .enumItems(model.getEnumItems())
            .enumComment(model.getEnumComment())
            .createBy(model.getCreateBy())
            .createDate(model.getCreateDate())
            .updateBy(model.getUpdateBy())
            .updateDate(model.getUpdateDate())
            .build();
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static FacadeEnumDo bo2Do(FacadeEnumBo bo) {
        if (bo == null) {
            return null;
        }
        FacadeEnumDo model = new FacadeEnumDo();
        model.setId(bo.getId());
        model.setEnumCode(bo.getEnumCode());
        model.setEnumName(bo.getEnumName());
        model.setEnumItems(bo.getEnumItems());
        model.setEnumComment(bo.getEnumComment());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<FacadeEnumBo> doList2BoList(List<FacadeEnumDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return null;
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(),FacadeEnumConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<FacadeEnumDo> boList2DoList(List<FacadeEnumBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return null;
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(),FacadeEnumConverter::bo2Do));
    }
}
